import 'package:freezed_annotation/freezed_annotation.dart';

import 'avatar_resp_list.dart';
import 'media_list.dart';

part 'af_user_info_model.freezed.dart';
part 'af_user_info_model.g.dart';

@freezed
class AfUserInfoModel with _$AfUserInfoModel {
  factory AfUserInfoModel({
    String? userId,
    int? userType,
    String? nickname,
    bool? isInternal,
    String? avatar,
    String? avatarUrl,
    String? avatarThumbUrl,
    String? avatarMiddleThumbUrl,
    String? mediumAvatar,
    List<dynamic>? mediumList,
    List<AvatarRespList>? avatarRespList,
    int? gender,
    String? birthday,
    int? age,
    String? language,
    String? country,
    List<MediaList>? mediaList,
    bool? isClub,
    String? about,
    bool? isAnswer,
    int? auditStatus,
    List<dynamic>? tagsList,
    List<dynamic>? tagDetails,
    String? rongcloudToken,
    bool? isRecharge,
    int? unitPrice,
    int? grade,
    bool? isVip,
    int? vipUnitPrice,
    int? guardianUnitPrice,
    int? guardianDiscountUnitPrice,
    int? level,
    int? followNum,
    int? praiseNum,
    bool? isBlock,
    bool? isSwitchNotDisturbIm,
    bool? isSwitchNotDisturbCall,
    bool? acceptMultipleCall,
    bool? isProbationPeriod,
    bool? isHavePassword,
    bool? isReview,
    bool? isFriend,
    bool? isMultiple,
    bool? hasEquity,
    String? createTime,
  }) = _AfUserInfoModel;

  factory AfUserInfoModel.fromJson(Map<String, dynamic> json) =>
      _$AfUserInfoModelFromJson(json);
}

extension AfUserInfoModelExt on AfUserInfoModel {
  DateTime get birthdayDate {
    if (birthday != null && birthday!.split('-').length == 3) {
      final List<String> list = birthday!.split('-');
      return DateTime(
          int.parse(list[0]), int.parse(list[1]), int.parse(list[2]));
    }
    return DateTime(1990, 01, 01);
  }
}
